import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/material.dart';
import '../../../app_files.dart';
import 'action.dart';
import 'state.dart';

Widget buildView(
    ReportProblemViewState state, Dispatch dispatch, ViewService viewService) {
  String contentStr =
      '尊敬的用户您好，${state.companyName}客户服务电话${state.consumerPhone}为您提供优质的服务。';

  return Scaffold(
    appBar: myAppBar(
      viewService.context,
      title: '故障报修',
      actions: [
        GestureDetector(
          behavior: HitTestBehavior.translucent,
          child: Container(
            padding: EdgeInsets.only(right: 12),
            height: 40,
            child: Center(
              child: Text(
                '拨打电话',
                style: TextThemeConfig.ActionBarTitle,
              ),
            ),
          ),
          onTap: () => CommonUtils.callPhone(
            state.consumerPhone,
            viewService.context,
          ),
        )
      ],
    ),
    backgroundColor: Colors.white,
    body: state.consumerPhone == null ? MyLoadingWidget() : Container(
      padding: EdgeInsets.only(top: 118),
      child: Column(
        children: [
          Image.asset('images/service_mobile.png'),
          Padding(
            padding: EdgeInsets.only(top: 15, bottom: 5),
            child: Text(
              '客户服务电话',
              style: TextThemeConfig.Font18WithBoldColor22,
            ),
          ),
          Text(
            state.consumerPhone,
            style: TextThemeConfig.Font15WithColor22,
          ),
          Container(
            margin: EdgeInsets.symmetric(horizontal: 50, vertical: 30),
            child: Center(
              child: Text(
                contentStr,
                style: TextThemeConfig.Font13WithColor66,
              ),
            ),
          ),
          Container(
            margin: EdgeInsets.only(top: 20),
            height: 40,
            width: 120,
            decoration: BoxDecoration(
              border: Border.all(
                color: ThemeConfig.mainColor,
              ),
              borderRadius: BorderRadius.all(Radius.circular(4)),
            ),
            child: GestureDetector(
              child: Center(
                child: Text(
                  '报修预约',
                  style: TextThemeConfig.Font14WithMainColor,
                ),
              ),
              behavior: HitTestBehavior.translucent,
              onTap: () => CommonUtils.checkUserLogin(viewService.context, () {
                CommonUtils.pushRoute(
                    viewService.context, RoutePath.gasUserAccountView,
                    arguments: {'type': 1});
              }),
            ),
          ),
        ],
      ),
    ),
  );
}
